<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编译时间</title>
    <style>
        table{border-collapse: collapse;}
        td{border: 1px solid #000;}
    </style>
</head>
<body>
    <div id="wp">正在执行，稍等。。。</div>
    <script id="tpl" type="text/html">
    <table>
    <caption>for循环输出两次</caption>
    <%var test = '输出自定义变量';%>
    <%for (var i = 0; i < 2; i++) {%>
    <tr><td>&lt;%=html%&gt;默认</td><td><%=html%></td></tr>
    <tr><td>&lt;%:h=html&gt;html转义</td><td><%:h=html%></td></tr>
    <tr><td>&lt;%:=html&gt;不转义</td><td><%:=html%></td></tr>
    <tr><td>&lt;%:u=url&gt;URI转义</td><td><%:u=url%></td></tr>
    <tr><td>var</td><td><%:=test%></td></tr>
    <tr><td>&lt;%=test + 1&gt;表达式</td><td><%=test + 1%></td></tr>
    <%if (true) {%>
        <tr><td>if</td><td>if 语句</td></tr>
    <%}%>
    <%}%>
    </table>
    </script>
    <script src="../template.js"></script>
    <script>
    var tpl = document.getElementById('tpl').innerHTML;
    var startTime = (new Date).getTime();
    var count = 100000;
    var i = count;
    while(i--) {
        template(tpl);
    }
    var endTime = (new Date).getTime(); 
    var time = (endTime - startTime);
    var averTime = time/count;

    document.getElementById('wp').innerHTML = '共 ' + count + '次, 总时间 ' + time + 'ms, 平均 ' + averTime + 'ms/次';
    </script>
</body>
</html>